import com.learn.LR1Analysis.LR1;
import com.learn.WordAnalysis.Analysis;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class LRoneTest01 {
    @Test
    public void test01(){
        //            w(i<j)A(k<j)oi=i+i-i;i=i+i#
        //String str = "w(i<j)A(k<j)oi=i+i-i;i=i+i#";
        Analysis analysis = new Analysis();
        //String str="while ( i < 5 ) or ( ( sum < 100 ) and ( count < 1.234e5 ) ) do i = i + k - 100 ; result = 1i + 1";
        //String str="while ( i < 5 ) or ( ( sum < 100 ) and ( count < 1.234e5 ) ) while do i = i + k - 100 ; result = i + 1";
        String str="while ( i < 5 ) or ( ( sum < 100 ) and ( count < 1.234e5 ) ) do while ( i < k ) do i = i + k - 100 ; result = i + 1";
        str= analysis.analysisString(str);
        LR1 lr=new LR1();
        lr.initialize("测试数据_5.txt");
        lr.output();
        lr.analyse(str);
        List<ArrayList<String>> ternaryFormulas = lr.getTernaryFormulas();
        for(List<String> list:ternaryFormulas){
            System.out.println(list.toString());
        }
    }

    @Test
    public void test02(){
        Analysis analysis = new Analysis();
        System.out.println(analysis.analysisString("while ( i < j ) or ( ( i < j ) and ( k < j ) ) do i = i + i - i ; i = i + i ; i = i"));
    }
}
